Skip to content

Fixes truncated error message "C extension: umpy.core.multiarray failed to import" #16366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

davidread
Copy link
Contributor

This occurred because lstrip is the wrong tool here:

>>> e = 'cannot import name numpy.core.multiarray'
>>> str(e).lstrip('cannot import name ')
'umpy.core.multiarray'

Better:

>>> str(e).replace('cannot import name ', '')
'numpy.core.multiarray'

--

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master --name-only -- '*.py' | flake8 --diff
  • whatsnew entry

…ed to import"

This occurred because lstrip is the wrong tool here:

>>> e = 'cannot import name numpy.core.multiarray'
>>> str(e).lstrip('cannot import name ')
'umpy.core.multiarray'

Better:

>>> str(e).replace('cannot import name ', '')
'numpy.core.multiarray'
@jreback
Copy link
Contributor

jreback commented May 16, 2017

can you post a minimal example that repros the incorrect message?

@codecov
Copy link

codecov bot commented May 16, 2017

Codecov Report

Merging #16366 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16366      +/-   ##
==========================================
- Coverage   90.38%   90.36%   -0.02%     
==========================================
  Files         161      161              
  Lines       50916    50916              
==========================================
- Hits        46021    46011      -10     
- Misses       4895     4905      +10
Flag Coverage Δ
#multiple 88.14% <ø> (-0.01%) ⬇️
#single 40.22% <ø> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.68% <0%> (-0.1%) ⬇️
pandas/core/indexes/datetimes.py 95.23% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d92f06a...eca0a14. Read the comment docs.

@codecov
Copy link

codecov bot commented May 16, 2017

Codecov Report

Merging #16366 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16366      +/-   ##
==========================================
- Coverage   90.38%   90.36%   -0.02%     
==========================================
  Files         161      161              
  Lines       50916    50916              
==========================================
- Hits        46021    46011      -10     
- Misses       4895     4905      +10
Flag Coverage Δ
#multiple 88.14% <ø> (-0.01%) ⬇️
#single 40.22% <ø> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.68% <0%> (-0.1%) ⬇️
pandas/core/indexes/datetimes.py 95.23% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d92f06a...eca0a14. Read the comment docs.

@jreback jreback added the Build Library building on various platforms label May 16, 2017
@davidread
Copy link
Contributor Author

Here's how I can reproduce it - by installing pandas 0.18 on my OSX (latest). I don't know why I get the error - I don't have pandas or numpy installed in the system-wide python or anything. I don't get the error message with pandas 0.21.1. But the actual error is by the by, as no doubt there are a few ways this can crop up.

dread@dmbp:~$ cd /tmp
dread@dmbp:/tmp$ virtualenv test
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6'
New python executable in /private/tmp/test/bin/python3.6
Also creating executable in /private/tmp/test/bin/python
Installing setuptools, pip, wheel...done.
dread@dmbp:/tmp$ . /private/tmp/test/bin/activate
(test) dread@dmbp:/tmp$ pip install pandas==0.18
Collecting pandas==0.18
Collecting python-dateutil>=2 (from pandas==0.18)
  Using cached python_dateutil-2.6.0-py2.py3-none-any.whl
Collecting numpy>=1.7.0 (from pandas==0.18)
  Using cached numpy-1.12.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting pytz>=2011k (from pandas==0.18)
  Using cached pytz-2017.2-py2.py3-none-any.whl
Requirement already satisfied: six>=1.5 in ./test/lib/python3.6/site-packages (from python-dateutil>=2->pandas==0.18)
Installing collected packages: python-dateutil, numpy, pytz, pandas
Successfully installed numpy-1.12.1 pandas-0.18.0 python-dateutil-2.6.0 pytz-2017.2
(test) dread@dmbp:/tmp$ python -c 'import pandas'
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "/private/tmp/test/lib/python3.6/site-packages/pandas/__init__.py", line 25, in <module>
    from pandas import hashtable, tslib, lib
ImportError: numpy.core.multiarray failed to import

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/test/lib/python3.6/site-packages/pandas/__init__.py", line 31, in <module>
    "extensions first.".format(module))
ImportError: C extension: umpy.core.multiarray failed to import not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.

@jreback jreback added this to the 0.21.0 milestone May 18, 2017
@jreback jreback merged commit 16c247b into pandas-dev:master May 18, 2017
@jreback
Copy link
Contributor

jreback commented May 18, 2017

thanks!

pcluo pushed a commit to pcluo/pandas that referenced this pull request May 22, 2017
@davidread davidread deleted the fix-stripped-chars-in-import-error branch June 7, 2017 10:56
stangirala pushed a commit to stangirala/pandas that referenced this pull request Jun 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants